/*******************************************************************************/
/* Author Olivier Grosse : http://codessources.votre-web.com                   */
/* Cookies manipulation functions                                              */
/*-----------------------------------------------------------------------------*/
/*  Modification of script from http://www.quirksmode.org/js/cookies.html      */
/*******************************************************************************/

//Ecrit un cookie
// return true si l'ecriture à eu lieu, false sinon
function createCookie(name,value,_days,_path)
{
	var expires='';
	var path='/';
	if(typeof(_path)!='undefined' && _path!=null) { path=_path; }

	if(typeof(_days)!='undefined' && _days!=null)
	{
		var date = new Date();
		date.setTime(date.getTime()+(_days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	}
	document.cookie = name+"="+value+expires+"; path="+path;
	return (value==readCookie(name));
}

//lit la valeur d'un cookie
// null si pas de cookie de ce nom trouve
// string valeur sinon
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') { c = c.substring(1,c.length); }
		if (c.indexOf(nameEQ) == 0)
		{
			return c.substring(nameEQ.length,c.length);
		}
	}
	return null;
}

//detruit un cookie a partir de son nom
function eraseCookie(name) { createCookie(name,"",-1); }